import { Dimensions, Platform } from "react-native";

var appInfo = require('react-native-device-info');

const ScreenWidth = Dimensions.get('window').width;
const ScreenHeight = Dimensions.get('window').height;

/**
 * @params GLOBAL里存放一些全局公共的变量
 */
export const GLOBAL = {
	CURR_ENV: 'TEST',
	CURR_MODULE: '2.0',
	SCREEN_HEIGHT: ScreenHeight,
	SCREEN_WIDTH: ScreenWidth,
	SCALE: ScreenWidth / 375,
	//提醒更新的间隔为8小时，即28800000ms
	UPDATE_DETECT_INTERVAL: 28800000,
	//手机型号
	IS_IPHONEX: isIphoneXorAbove(),
	IS_EMULATOR: appInfo.isEmulator(),
	IS_ANDROID: Platform.OS === 'android',
	PLATFORM_OS: Platform.OS,
	VERSION: appInfo.getVersion(),
	VERSION_CODE: appInfo.getBuildNumber(),
	APP_STATE: "active" // app应用程序被暂时放到了后台，或者又重新回到前台
}

export const NAVIGATIONS = {}

function isIphoneXorAbove() {
	const dimen = Dimensions.get('window');
	return (
		Platform.OS === 'ios' &&
		!Platform.isPad &&
		!Platform.isTVOS &&
		((dimen.height === 812 || dimen.width === 812) || (dimen.height === 896 || dimen.width === 896))
	);
}
